﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbXrefGraph : OdDbGraph
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbXrefGraph(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbXrefGraph_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbXrefGraph obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbXrefGraph()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbXrefGraph(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdDbXrefGraph() : this(TD_DbPINVOKE.new_OdDbXrefGraph(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbXrefGraphNode xrefNode(string name)
		{
			OdDbXrefGraphNode result = (OdDbXrefGraphNode)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbXrefGraph_xrefNode__SWIG_0(this.swigCPtr, name), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbXrefGraphNode xrefNode(OdDbObjectId blockId)
		{
			OdDbXrefGraphNode result = (OdDbXrefGraphNode)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbXrefGraph_xrefNode__SWIG_1(this.swigCPtr, OdDbObjectId.getCPtr(blockId)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbXrefGraphNode xrefNode(OdDbDatabase pDb)
		{
			OdDbXrefGraphNode result = (OdDbXrefGraphNode)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbXrefGraph_xrefNode__SWIG_2(this.swigCPtr, OdDbDatabase.getCPtr(pDb)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbXrefGraphNode xrefNode(int nodeIndex)
		{
			OdDbXrefGraphNode result = (OdDbXrefGraphNode)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbXrefGraph_xrefNode__SWIG_3(this.swigCPtr, nodeIndex), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbXrefGraphNode hostDwg()
		{
			OdDbXrefGraphNode result = (OdDbXrefGraphNode)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbXrefGraph_hostDwg(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool markUnresolvedTrees()
		{
			bool result = TD_DbPINVOKE.OdDbXrefGraph_markUnresolvedTrees(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static void getFrom(OdDbDatabase pDb, OdDbXrefGraph xrefGraph, bool includeGhosts)
		{
			TD_DbPINVOKE.OdDbXrefGraph_getFrom__SWIG_0(OdDbDatabase.getCPtr(pDb), OdDbXrefGraph.getCPtr(xrefGraph), includeGhosts);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void getFrom(OdDbDatabase pDb, OdDbXrefGraph xrefGraph)
		{
			TD_DbPINVOKE.OdDbXrefGraph_getFrom__SWIG_1(OdDbDatabase.getCPtr(pDb), OdDbXrefGraph.getCPtr(xrefGraph));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
